/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2024.
 * Description: RTOS SELinux object permissive label feature
 * Author: wanghuizhao
 * Create: 2023-09-07
 */

static int __init type_permissive_setup(char *str)
{
	unsigned long mode;

	if (!kstrtoul(str, 0, &mode))
		type_permissive = mode ? TYPE_PERMISSIVE_OBJECT :
					TYPE_PERMISSIVE_DOMAIN;
	return 1;
}
__setup("type_permissive=", type_permissive_setup);

static bool check_permissive_type(struct policydb *policydb,
					const struct context *scontext,
					const struct context *tcontext)
{
	if (type_permissive == TYPE_PERMISSIVE_DOMAIN) {
		/* permissive domain checking */
		if (ebitmap_get_bit(&policydb->permissive_map, scontext->type))
			return true;
	} else {
		/* permissive object checking */
		if (ebitmap_get_bit(&policydb->permissive_map, tcontext->type))
			return true;
	}

	return false;
}
